package com.lcf.system.controller;


import com.lcf.framework.annotation.PermissionCheck;
import com.lcf.system.dto.role.RoleMenuDTO;
import com.lcf.system.service.SysRoleMenuService;
import com.lcf.system.vo.roleMenu.SysRoleMenuVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import static com.lcf.framework.enums.PermissionEnum.*;
/**
 * 角色与菜单(SysRoleMenu)表控制层
 *
 * @author lcf
 * @since 2025-02-28 13:28:47
 */
@Tag(name = "角色与菜单")
@RestController
@RequestMapping("sysRoleMenu")
public class SysRoleMenuController {
    @Resource
    private SysRoleMenuService sysRoleMenuService;

    /**
     * 设置角色菜单权限
     */
    @Operation(summary = "设置角色菜单权限")
    @PermissionCheck(SYS_ROLE_MENU_SET)
    @PostMapping("{roleId}")
    public void setRoleMenu(@PathVariable @Schema(description = "角色ID") long roleId,
                            @RequestBody RoleMenuDTO roleMenu) {
        sysRoleMenuService.setRoleMenu(roleId, roleMenu);
    }

    /**
     * 查看角色菜单列表
     */
    @Operation(summary = "查看角色菜单列表")
    @PermissionCheck(SYS_ROLE_MENU_LIST)
    @GetMapping("list/{roleId}")
    public List<SysRoleMenuVO> getRoleMenuList(@PathVariable @Schema(description = "角色ID") long roleId) {
        return sysRoleMenuService.getRoleMenuList(roleId);
    }
}

